<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body >
	<div id="example-1">
		<div :style="{fontSize:postFontSize + 'em'}">
		<blog-post v-on:enlarge-text="postFontSize += 0.1" v-for="post in posts" v-bind:key="post.id" v-bind:post="post"></blog-post>
		</div>
		<custom-input v-model="searchText"></custom-input>
		
		<alert-box>
		  Something bad happened.1
		</alert-box>
	</div>
	
		
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.js"></script>
<script>
	Vue.component('alert-box', {
	  template: `
		<div class="demo-alert-box">
		  <strong>Error!</strong>
		  <slot></slot>
		</div>
	  `
	})
	Vue.component('blog-post', {
		props:['post'],
		template:'<div class="blog-post"><h3>{{post.title}}</h3><button v-on:click="$emit(\'enlarge-text\')">enlarge text</button><div v-html="post.content"></div></div>',
	});
	Vue.component('custom-input', {
		props:['value'],
		template:'<input v-bind:value="value" v-on:input="$emit(\'input\', $event.target.value)"/>',
	});
	var vm = new Vue({
		el:'#example-1',
		data:{
			postFontSize:1,
			searchText:'12',
			posts:[
					{id:1,title:'My journey with Vue',content:'111'},
					{id:2,title:'Blogging with Vue',content:'222'},
					{id:3,title:'Why Vue is so fun',content:'333'},
				]
		}
	});
	
</script>
</html>



















































